import {Material,Color} from '@cesiumjs';
import {G3xObjBase} from "@g3xObjBase"
import {
  g3x_defineProperty,
  g3x_defineReadonly,
  track,
  bind
} from "@g3x/utils";
import {
  autorun,
  reaction,
  intercept,
  extendObservable,
  computed
} from 'mobx';

/* 20 */

/**
 * 折线材质
 * @namespace
 * @name Material
 * @memberof Obj.Polyline
 */

/**
 * 纯色材质
 * @class
 * @memberof Obj.Polyline.Material
 * @extends XbsjBase
 */

let aaa = G3xObjBase;

class G3xColor extends G3xObjBase{
  constructor(viewer, readyCallback) {
    super();

    const _this = this;

    extendObservable(_this, {
      _material: Material.fromType('Color'),
      get material() {
        return this._material;
      }
    }, {
      material: computed
    })

    const {disposers,material,defaultOptions} = _this;

    disposers.push(autorun(function() {
      material.uniforms.color = new (Function.prototype.bind.apply(Color, [null,...defaultOptions.color]))();
    }));
  }
}

G3xColor.defaultOptions = {
  /**
   * 颜色叠加
   * @type {array}
   * @instance
   * @default [1, 1, 1, 1]
   * @memberof Obj.Polyline.Material.Color
   */
  color: [1, 1, 1, 1]
  // color: { type: 'array', items: { type: 'number' }, minItems: 4, maxItems: 4, default: [1, 1, 1, 1], description: '颜色叠加'},
};

export default G3xColor;
